<template>
	<view class="blindbox_deta">
		<Navbar>盲盒详情</Navbar>
		<scroll-view scroll-y class="scroll_view">
			<view>
				<view class="banner">
					<view class="show_view">
						<image :src="`${baseImageUrl}/home/type2.png`" class="label"></image>
						<image :src="cover" class="cover"></image>
						<view class="status">{{type_name}}</view>
					</view>
				</view>
				<view class="content">
					<view class="info">
						<view class="name">{{name}}</view>
						<view class="number">发行：{{issue}}份</view>
					</view>
					<view class="sub_title">
						<image :src="`${baseImageUrl}/home/xs2.png`"></image>
						<text>盲盒详情</text>
					</view>
					<view class="u_parse">
						<u-parse :content="content" :previewImg="false"></u-parse>
					</view>
				</view>
			</view>
		</scroll-view>
		<view class="footer">
			<view class="price">
				<text class="key">¥</text>
				<text class="value">{{price}}</text>
			</view>
			<view class="btn not" v-if="status==0">未开始</view>
			<view class="btn" @click="submit" v-else-if="status==1">立即购买</view>
			<view class="btn not" v-else-if="status==2">已结束</view>
			<view class="btn not" v-else-if="status==3">已售罄</view>
		</view>
	</view>
</template>

<script>
	import {
		purchaseInfo,
		orderPlace
	} from '@/request/api.js';
	export default {
		data() {
			return {
				id: null,
				status: -1,

				cover: "",
				type_name: "",
				name: "",
				issue: "",
				price: "",
				content: ""
			}
		},
		onLoad(option) {
			this.id = option.id;
			this.getDeta();
		},
		methods: {
			async getDeta() {
				let {
					info,
					product
				} = await purchaseInfo({
					id: this.id
				});
				this.status = info.status;
				this.cover = product.cover;
				this.type_name = product.type_name;
				this.name = product.name;
				this.issue = quota;
				this.price = product.price;
				this.content = product.content;
			},
			async submit() {
				let {
					id
				} = await orderPlace({
					id: this.id
				});
				this.router(`/pages/common/order_deta?id=${id}`);
			}
		}
	}
</script>

<style scoped lang="scss">
	* {
		font-family: LiSu;
	}

	$footerHeight: 157rpx;

	.blindbox_deta {
		height: 100vh;
		background: #29170D;

		.scroll_view {
			height: calc(100vh - #{$navbarHeight} - #{$footerHeight});

			.banner {
				width: 100%;
				height: 730rpx;
				padding: 80rpx 75rpx 50rpx;
				box-sizing: border-box;
				background: url(#{$baseImageUrl}/home/i2.png) no-repeat;
				background-size: 100% 100%;

				.show_view {
					width: 100%;
					height: 100%;
					position: relative;

					.label {
						width: 102rpx;
						height: 130rpx;
						position: absolute;
						left: 10rpx;
						top: 0;
						z-index: 2;
					}

					.status {
						width: 100%;
						height: 80rpx;
						line-height: 50rpx;
						text-align: center;
						color: #4E2D11;
						font-size: 32rpx;
						font-weight: 400;
						background: url(#{$baseImageUrl}/common/time.png) no-repeat;
						background-size: 100% 100%;
						position: absolute;
						left: 0;
						bottom: 0;
						z-index: 2;
					}

					.cover {
						width: 100%;
						height: 100%;
					}
				}

			}

			.content {
				padding: 0 30rpx;
				box-sizing: border-box;

				.info {
					width: 100%;
					height: 174rpx;
					background: url(#{$baseImageUrl}/bg/688_174.png) no-repeat;
					background-size: 100% 100%;
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;

					.name {
						color: #494338;
						font-size: 50rpx;
						font-weight: 400;
					}

					.number {
						width: 246rpx;
						height: 44rpx;
						line-height: 44rpx;
						text-align: center;
						color: #FFFFFF;
						font-size: 28rpx;
						font-weight: 400;
						background: url(#{$baseImageUrl}/common/label2.png) no-repeat;
						background-size: 100% 100%;
					}
				}

				.sub_title {
					height: 98rpx;
					display: flex;
					align-items: center;

					image {
						width: 32rpx;
						height: 32rpx;
					}

					text {
						color: #FFFFFF;
						font-size: 32rpx;
						font-family: SimSun;
						font-weight: 400;
						padding-left: 12rpx;
						box-sizing: border-box;
					}
				}

				.u_parse {
					color: #fff;
					font-family: SimSun;
				}
			}
		}

		.footer {
			width: 100%;
			height: $footerHeight;
			background: #29170D;
			border-top: 2px solid #BC8478;
			padding: 14rpx 30rpx;
			box-sizing: border-box;
			display: flex;
			justify-content: space-between;

			.price {
				color: #FFFFFF;
				font-weight: 400;
				font-family: SimSun;

				.key {
					font-size: 28rpx;
				}

				.value {
					font-size: 40rpx;
				}
			}

			.btn {
				width: 210rpx;
				height: 80rpx;
				line-height: 80rpx;
				text-align: center;
				color: #FFFFFF;
				font-size: 30rpx;
				font-weight: 400;
				font-family: SimSun;
				background: url(#{$baseImageUrl}/common/btn.png) no-repeat;
				background-size: 100% 100%;

				&.not {
					background: url(#{$baseImageUrl}/common/btn2.png) no-repeat;
					background-size: 100% 100%;
				}
			}
		}
	}
</style>